/*
 * @Description: 打印按钮
 * @Author: Rfan
 * @Date: 2022-11-05 19:35:12
 * @LastEditTime: 2023-01-06 14:08:16
 */

import { useMemo, useState } from 'react';
import { Button } from 'antd';
import { useLevelTableContext } from '@/components/LevelTable/contexts/LevelTableContext';
import PrintDialog from '../dialogs/Print';

interface IPrintBtnProps {
  selectItems: number[];
  selectAt: any;
}
const PrintBtn = (props: IPrintBtnProps) => {
  const { selectItems, selectAt } = props;

  const [visible, setVisible] = useState(false);

  return (
    <>
      <Button onClick={() => setVisible(true)} disabled={selectItems.length < 1}>
        打印
      </Button>

      {useMemo(
        () => (
          <PrintDialog
            baseInfo={selectAt}
            visible={visible}
            selectItems={selectItems}
            onClose={() => {
              setVisible(false);
            }}
          />
        ),
        [visible, selectItems]
      )}
    </>
  );
};

export default PrintBtn;
